package pw.canyingisme.plugin.occupation;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitRunnable;
import pw.canyingisme.plugin.config.ConfigLoader;

import java.util.Set;

public class OccupationEffectTask extends BukkitRunnable {

    @Override
    public void run() {
        Bukkit.getOnlinePlayers().forEach(this::EffectApply);
    }
    public void EffectApply(Player p) {
        Set<String> effs = ConfigLoader.getOccupationEffectList(ConfigLoader.getPlayerOccupation(p.getName()));
        for (String eff : effs) {
            PotionEffect effect = new PotionEffect(ConfigLoader.effectGetMCEffect(ConfigLoader.getPlayerOccupation(p.getName()), eff), 200, ConfigLoader.getOccupationEffectLevel(ConfigLoader.getPlayerOccupation(p.getName()), eff));
            effect.apply(p);
        }
    }

}
